#coding:utf-8
import json
from django.http import  HttpResponse,HttpResponseRedirect
def ajax_http(func):	######传入视图
	def w(request,*args,**kws): #########这个是视图的request参数
		if request.method=='GET':callback=request.GET.get('callback')
		else:callback=None
		info=func(request)  #####视图返回的是info json，这里执行了该视图后，直接进行扫尾
		if isinstance(info,HttpResponseRedirect):
			return info
		info=json.dumps(info,encoding='utf-8',ensure_ascii=False)
		if callback is None:
                	info=info
		else:
			info="%s(%s)"  % (callback,info)
		response=HttpResponse(info)
		return response
	return w

		
		
		
